<template>
	<view>
		<image class="w-1 absolute-0" style="height: 440rpx;" :src="$path + '/tab4/ubg.png'" mode=""></image>
		<view class="sticky o-h">
			<up-navbar title="共享电工" placeholder leftIconSize="0" bgColor="transparent" :autoBack="false">
				<template #center>
					<view class="c-ff bold fs-36">我的</view>
				</template>
			</up-navbar>
			<image class="w-1 absolute-0" style="height: 524rpx;" :src="$path + '/tab4/ubg.png'" mode=""></image>
		</view>


		<view class="w-1 p-r-30 fl-s-s relative">
			<view class="p-l-30  w-1 fr-s-c" @click="$to('/pagemaster/pages/User/UserInfo')">
				<image class="circle" style="width: 120rpx; height: 120rpx; border: 2rpx solid #ffffff;"
					:src="user.avatar || '/static/logo.png'" mode="aspectFill"></image>
				<view class="flex-1 fl-c-s m-l-20">
					<text class="c-ff fs-32">{{user.nickname || '点击登录'}}</text>
					<text class="c-ff fs-24 m-t-10" v-if="user">{{phoneStar(user.mobile)}}</text>
				</view>
				<image style="width: 44rpx; height: 44rpx;" :src="$path + '/tab4/right.png'" mode=""></image>
			</view>

			<view class="bg-ff br-20 p-30 fl-s-s w-1 m-t-45" @click="$to('/pagemaster/pages/User/MyWallet')"
				style="height: 244rpx;">
				<text class="c-00 fs-28 bold">钱包</text>
				<!-- <image style="width: 35rpx; height: 35rpx;" :src="$path + '/tab4/rights.png'" mode=""></image> -->
				<view class="w-1 fl-c m-t-15">
					<view class="fr-s-c" @click.stop="show=!show">
						<view class="c-33 bold m-r-10">
							<price v-if="show" :price="user.money || 0"></price>
							<text class="fs-48" v-else>****</text>
						</view>
						<up-icon color="#cfcfcf" size="40rpx" :name="show?'eye-fill':'eye-off'"></up-icon>
					</view>
					<view class="fr-c m-t-5" @click.stop="$to('/pagemaster/pages/User/Withdrawal')">
						<text class="fs-28" style="color: #3E8BFF;">去提现</text>
						<up-icon color="#3E8BFF" size="30rpx" name="arrow-right"></up-icon>
					</view>
				</view>
			</view>


			<view class="bg-ff br-20  fl-s-s w-1 m-t-20">
				<text class="c-00 fs-28 bold p-30">更多工具</text>
				<view class="w-1 warp fr-s-s">
					<view class="fl-c m-b-25 relative" @click="tonext(item)" v-for="(item,index) in menus" :key="index" style="width: 25%;">
						<image class="" :src="`/static/images/tab4/n${index+1}.png`"
							style="width: 80rpx; height: 80rpx;" mode=""></image>
						<text class="fs-24 c-33">{{item.name}}</text>
						<!-- #ifdef MP-WEIXIN -->
						<button class="w-1 h-1 absolute-0" style="opacity: 0;" v-if="index==1"
							open-type="contact"></button>
						<!-- #endif -->
					</view>
				</view>
				<view style="height: 20rpx;"></view>
			</view>
		</view>

	</view>

</template>

<script setup>
	import {
		phoneStar
	} from '@/utils/util.js'
	import {
		onMounted,
		reactive
	} from 'vue';

	const show = ref(true)
	const orders = reactive([
		'待接单',
		'已接单',
		'服务中',
		'已完成',
		'全部订单',
	])


	const menus = reactive([{
			name: '意见反馈',
			url: '/pagemaster/pages/User/FeedBack'
		}, {
			name: '在线客服',
			url: ''
		}, {
			name: '银行卡管理',
			url: '/pagemaster/pages/User/ManageCard'
		},
		{
			name: '关于我们',
			url: '/pagemaster/pages/User/AboutUs'
		}, {
			name: '修改密码',
			url: '/pagemaster/pages/Login/ForgetPwd'
		},
		{
			name: '设置',
			url: '/pagemaster/pages/User/Set'
		}
	])

	function tonext(item) {
		if (item.url) {
			uni.$to(item.url)
		} else {
			// #ifdef APP-PLUS
			uni.$u.toast('请配置企业微信后再使用~');
			// #endif
		}
	}


	const user = ref('')
	// onLoad(() => {
	// 	user.value = uni.getStorageSync('user') || '';
	// })
	onMounted(()=>{
		user.value = uni.getStorageSync('user') || '';
	})
	onShow(() => {
		if (uni.getStorageSync('user')) {
			getuser()
		}
	})

	function getuser() {
		if (!uni.getStorageSync('user')) return;
		uni.$post({
			url: '/api/User/Userinfo',
			// url:'/api/User/getmybasic',
			loading: false
		}).then(res => {
			user.value = res.data;
			let token = uni.getStorageSync('user').token
			user.value.token = token;
			uni.setStorageSync('user', user.value)
		})
	}
</script>

<style>
	page {
		background: #f1f5f6;
	}
</style>